package com.example.mapper;

import com.example.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {
//    @Select("select count(*) from tlias.emp")
//    public Long count();

//    /**
//     * 分页查询获取列表数据
//     * @param start
//     * @param size
//     * @return
//     */
//    @Select("select * from tlias.emp limit #{start},#{size}")
//    public List<Emp> page(Integer start, Integer size);
//@Select("select * from tlias.emp")
    public List<Emp> list(String name, Short gender, LocalDate begin,LocalDate end);

    void delete(List<Integer> ids);

    /**
     * 添加员工
     * @param emp
     */
   @Insert("insert into tlias.emp (username,  name, gender, image, job, entrydate, dept_id, create_time, update_time) " +
           "values (#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);

    /**
     * 根据id查询
     * @param id
     * @return
     */
   @Select("select * from tlias.emp where id = #{id}")
   Emp getById(Integer id);

    /**
     * 更新员工
     */
   void update(Emp emp);

    /**
     * 根据用户名和密码查询员工
     * @param emp
     * @return
     */
    @Select("select * from tlias.emp where username=#{username} and password=#{password}")
   Emp getByUsernameAndPassword(Emp emp);

    /**
     * 根据部门id删除员工数据
     * @param deptId
     */
    @Delete("delete from tlias.emp where dept_id = #{deptId}")
    void deleteByDeptId(Integer deptId);
}
